//
//  MKUITestCircleGestureView.h
//  MKUITestApp
//  手势控件，可以用于手势解锁功能
//  Created by 苏尚进 on 2025/8/7.
//  Copyright © 2025 moon. All rights reserved.
//

#import <UIKit/UIKit.h>

NS_ASSUME_NONNULL_BEGIN
@class MKUITestCircleGestureView,MKUITestCircleCellBase;
@protocol MKUITestCircleGestureViewDelegate <NSObject>
@optional
//即将开始手势滑动
- (void)circleGestureViewWillBeginTouching:(MKUITestCircleGestureView *)circleGestureView;
//结束手势滑动
- (void)circleGestureViewDidEndTouching:(MKUITestCircleGestureView *)circleGestureView;
//手势滑动时，选中的序列变更通知
- (void)circleGestureView:(MKUITestCircleGestureView *)circleGestureView didSelectedCircleIndexes:(NSArray<NSNumber *> *)selectedCircleIndexes;
@end

@interface MKUITestCircleGestureView : UIView
@property(nonatomic,assign,nullable) id<MKUITestCircleGestureViewDelegate> delegate;
@property(nonatomic,readonly) NSInteger cols;//列数，默认为3
@property(nonatomic,readonly) NSInteger rows;//行数，默认为3

@property(nonatomic,assign) UIEdgeInsets contentInsets;//内边距，默认为(0,0,0,0)
@property(nonatomic,assign) CGFloat circleInteritemSpacing;//圆圈之间的间隔，默认为10
@property(nonatomic,assign) CGFloat minCircleInteritemSpacing;//最小的圆圈之间的间隔，默认为2

@property(nonatomic,assign) CGFloat circleRadius;//圆圈半径值，默认为22
@property(nonatomic,assign) CGFloat minCircleRadius;//最小的圆圈半径值，默认为11

@property(nonatomic,assign) CGFloat lineWidth;//圆圈之间连线的线宽度，默认为1
@property(nonatomic,strong,nullable) UIColor *lineColor;//圆圈之间连线的颜色值，默认为UIColor.systemBlueColor

@property(nonatomic,assign) Class circleCellClass;//圆圈视图类，默认为MKUITestCircleCell。设置时，会同步修改self.lineColor = [circleCellClass tintColorWithSelected:YES]
@property(nonatomic,readonly) NSArray<__kindof MKUITestCircleCellBase *> *circleCells;

@property(nonatomic,assign) BOOL isTrackHidden;//是否隐藏轨迹，默认为NO

- (id)initWithCols:(NSInteger)cols rows:(NSInteger)rows;

@property(nonatomic,readonly) BOOL isTouching;//是否正在手势滑动中
@property(nonatomic,assign) BOOL clearSelectionWhenTouchBegin;//是否在手势开始时，清空选择，默认为YES

@property(nonatomic,strong,nullable) NSArray<NSNumber *> *selectedCircleIndexes;//选择的圆圈索引序列数组，从0开始

/// 判断手势序列有几个转折点
/// - Parameters:
///   - selectedCircleIndexes: 手势序列，从0开始
///   - cols: 手势的列数
+ (NSInteger)turnsCountWithSelectedCircleIndexes:(NSArray<NSNumber *> *)selectedCircleIndexes cols:(NSInteger)cols;
@end

//圆圈视图基类。默认显示边框（线宽为1，选中是颜色为蓝色，未选中为灰色）
@interface MKUITestCircleCellBase : UIView
@property(nonatomic,readonly) NSInteger cellIndex;//当前圆圈视图的索引位置，从0开始
@property(nonatomic,readonly) BOOL selected;//是否选中
@property(nonatomic,readonly) BOOL isTrackHidden;//是否隐藏轨迹
- (void)setSelected:(BOOL)selected animated:(BOOL)animated;

/// 返回选中或未选中时的颜色值。该颜色值用于边框、背景等。默认选中为UIColor.systemBlueColor，未选中为UIColor.systemGrayColor
/// - Parameter selected: 是否选中
+ (nullable UIColor *)tintColorWithSelected:(BOOL)selected;
//刷新样式
- (void)reloadCell;
@end

//提供此类的圆圈视图：选中时中间显示一个圆圈（颜色为UIColor.systemBlueColor）
@interface MKUITestCircleCell : MKUITestCircleCellBase
@property(nonatomic,readonly) UIView *centerCircleView;//中心圆圈视图，背景色为UIColor.systemBlueColor
@end
NS_ASSUME_NONNULL_END
